/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.so.vezbac;

import domen.OpstiDomenskiObjekat;
import domen.Vezbac;
//import java.sql.SQLException;
import java.util.Iterator;
import java.util.LinkedList;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import server.baza.DataBaseBroker;
import server.so.OpstaSO;

/**
 *
 * @author Ivan Ivic
 */
public class PronadjiVezbace extends OpstaSO {
    private LinkedList<Vezbac> listaVezbaca;

    public LinkedList<Vezbac> getListaVezbaca() {
        return listaVezbaca;
    }
        
    public synchronized static LinkedList<Vezbac> pronadjiVezbace(Vezbac vezbac)
    {
        PronadjiVezbace pv = new PronadjiVezbace();
        pv.opsteIzvrsenjeSO(vezbac);
        return pv.getListaVezbaca();
    }

    @Override
    public int izvrsenjeSO(OpstiDomenskiObjekat odo) {
        Vezbac v = (Vezbac) odo;
        LinkedList<OpstiDomenskiObjekat> l = new LinkedList<OpstiDomenskiObjekat>();
        listaVezbaca = new LinkedList<Vezbac>();

        l = DataBaseBroker.getDbb().pronadji(v);
        Iterator i = l.iterator();
        while (i.hasNext()) {
            listaVezbaca.add((Vezbac) i.next());
        }
        // signal = 9015;  // 9015
        signal = DataBaseBroker.getDbb().getSignal();
        return signal;
    }

    @Override
    public boolean stanjeOperacije(int signal) {
        switch(signal)
        {
            case 9015:
                prikazi(signal, "Slog pronadjen");
                return true;
            case 9016:
                prikazi(signal, "Slog nije pronadjen");
                return false;
            default:
                return false;
        }
    }    
}
